var sysRecordTable;
$(function () {
    sysRecordTable = $('#systemRecordTable').dataTableExtend({
        "ajax": sysInfo.basePath+"/sys_record/credential_sys_record_data.do",
        "fnServerParams": function (aoData) {
            aoData = $.extend(aoData, getSearchData());
            return aoData;
        },
        "aoColumns": [
            {
                "title":"序号",
                "render": function (data, type, full, meta) {
                    return meta.row+1;
                },
                "orderable": false
            },
            {
                "title":"所属事业部",
                "data": "signOrgName",
                "orderable": false
            },
            {
                "title":"业务编号",
                "data": "workNo",
                "orderable": false
            },
            {
                "title":"证书名称",
                "data": "certificateName",
                "orderable": false
            },
            {
                "title":"证书编号",
                "data": "certificateCode",
                "orderable": false
            },
            {
                "title":"证书类型",
                "data": "certificateType",
                "orderable": false,
            },
            {
                "title":"操作类型",
                "data": "operateType",
                "orderable": false,
                "render":function (data, type, full, meta) {
                    var str = "";
                    for(var key in operType){
                        if(key == data){
                            str = operType[key];
                            break;
                        }
                    }
                    return str;
                }
            },
            {
                "title":"操作时间",
                "data": "operateTime"
            },
            {
                "title":"操作人",
                "data": "operaterName",
                "orderable": false
            },
            {
                "title":"备注",
                "data": "remarks",
                "orderable": false
            }
        ],
    });

    // 加载事业部
    syb("#signOrgName");
    // 初始化操作类型下拉框
    var option = "";
    for(var key in operType){
        option += '<option value="'+key+'">'+operType[key]+'</option>'
    }
    $('[name="operateType"]').append(option).select2({
        placeholder: "请选择",
        allowClear: true,
        language: "zh-CN"
    });

});

function searchSysRecordTable(){
    sysRecordTable.ajax.reload();
}

/**
 * 获取搜索数据
 * @returns {*|jQuery}
 */
function getSearchData() {
    return $('#sysRecordControllerForm').serializeObject();
}

/**
 * 导出
 */
function exportData(){
    var params = $('#sysRecordControllerForm').serialize();
    console.log(params);
    window.location.href = encodeURI(sysInfo.basePath+"/sys_record/export_sys_record.do?"+params);
}